﻿using System;
using System.Globalization;

namespace BizElements.BusinessLayer
{
    /// <summary>A method which ensures that the message source is initialized.</summary>
    /// <param name="textSource">A reference to a non-serializable class field points an ITextSource object or null. 
    /// If the field points to a null reference, the method will initialize it.</param>
    /// <param name="cultureName">A reference to a serializable class field which contains the name of the culture used by the <b>textSource</b>.</param>
    public delegate void TextSourceInitializer(ref ITextSource textSource, ref string cultureName);

    /// <summary>Multilingual text source.</summary>
    public interface ITextSource
    {
        #region Properties.

        /// <summary>
        /// Current culture.
        /// </summary>
        CultureInfo CurrentCulture { get; set; }

        #endregion

        #region Methods.

        /// <summary>
        /// Gets string with the specified key. Text is in current culture language.
        /// </summary>
        /// <param name="key">Unique key in a text source.</param>
        /// <returns>String that matches the given key. Null if it doesn't exist.</returns>
        string GetString(string key);

        /// <summary>
        /// Gets string with the given key written for the specified culture/language.
        /// </summary>
        /// <param name="key">Unique key in a text source.</param>
        /// <param name="culture">Specifies culture and language of the requested string.</param>
        /// <returns>String that matches the given key. Null if it doesn't exist.</returns>
        string GetString(string key, CultureInfo culture);

        /// <summary>
        /// Resets CurrentCulture property.
        /// </summary>
        void UseDefaultCulture();

        #endregion
    }
}